/*
 * osc_header.h
 *
 *  Created on: Oct 20, 2012
 *      Author: andrey
 */

#ifndef OSC_HEADER_H_
#define OSC_HEADER_H_

#include "main.h"

/* Total number of channels to be sampled by a single ADC operation.*/
#define ADC_NUMBER_CHANNELS   6

/* total number of data snapshots we care about */
#define ADC_SAMPLES_COUNT 256

#define ADC_SAMLLES_INITIAL 72

// this structure contains one multi-channel ADC state snapshot
typedef struct {
	adcsample_t adc_data[ADC_NUMBER_CHANNELS];
	time_t time;
} adc_state;

typedef struct {
	adc_state states[ADC_SAMPLES_COUNT];
	int tail;
} adc_snapshot;

void initOscState();
int isHigh(adcsample_t level);
void addState(adc_state *source);
void copySnapshot(adc_snapshot *dest);
void clearSnapshot(adc_snapshot *dest);
int findIndexForTime(time_t time, adc_snapshot *data);
void resetSnapshot();
void printOscData(adc_snapshot *data);

int getAdcSamplesCount();
void setAdcSamplesCount(int value);

#endif /* OSC_HEADER_H_ */
